package worker

import "learngo/crawler/engine"

type CrawlService struct{}

//接收到序列化的Request后，需要将Request反序列化成真正的Request
func (CrawlService) Process(req Request, result *ParseResult) error {
	engineReq, err := DeserializeRequest(req)
	if err != nil {
		return err
	}

	//engineResult是解析网站后的结果
	engineResult, err := engine.Worker(engineReq)
	if err != nil {
		return err
	}

	//将结果序列化成字符串
	*result = SerializeResult(engineResult)
	return nil
}
